class BaseException(Exception):
	"""Base class for all AstBridge exceptions."""
	_prefix = 'AstBridge Base Exception'
	_error = '(no error)'
	def __init__(self, error):
		self._error = error
	def __str__(self):
		return '%s: %s' % (self._prefix, self._error)

class IncorrectBanner(BaseException):
	_error = 'Incorrect Asterisk Banner'

class AuthenticationFailure(BaseException):
	_error = 'Authentication failed'

class CommunicationError(BaseException):
    'This exception is raised when the PBX responds in an unexpected manner.'
    def __init__(self, packet, msg = None):
        e = 'Unexpected response from PBX: %r\n' % (msg,)
        self._error = e + ': %r' % (packet,)

class GoneAwayError(BaseException):
    'This exception is raised when the Manager connection becomes closed.'
    _error = 'The connection to AstBridge is gone!'

class ActionFailed(BaseException):
	'This exception is raised when a PBX action fails.'
	_prefix = 'AstBridge action failed'
	_error = 'Failed to send action to Asterisk AMI'


